For this lab, you will be assigned a Key Plain Cipher triple to use. The triple is written as three values in hexadecimal being the key (128/192/256 bits), plaintext (128 bits) and ciphertext (128 bits) values respectively; and should look something like the following:
000102030405060708090a0b0c0d0e0f 00112233445566778899aabbccddeeff 69c4e0d86a7b0430d8cdb78070b4c55a
If you encrypt the specified plaintext with the key, you should get
the ciphertext value; if you decrypt the ciphertext value, you should
get the plaintext value. Depending on the trace level specified, you will
also be given details of the round calculations as they are computed.
You can run the AES Calculator Applet in the following ways:
appletviewer AEScalc.html" from the Java SDK distribution,
to run the applet.
Please note that the applet has limited error handling, supplying an incorrect input value is liable to generate nonsense results!
The table below lists triples on the left with the login of the person they are allocated to on the right (nb. you may need to scroll the window to see the logins). These were randomly generated using the GenAES program, which is also included in the JAR file, and which generates n random triples when run as:
java -cp AEScalc.jar GenAES n
Triple (key plain cipher)in Hexadecimal Login 7fab598e7931dd744e9e0626994d07e6 f77312ea0d1367311e0f79802c04cc67 27da9045d7f3f47d0b2a59c6b16bec6f xxx
For the second part of this lab, using your original plaintext and key values, you should calculate the value of the initial AddRoundKey stage, and all of the stages in round one (the 1st full round) by hand.
Firstly you need to determine the subkeys used by these stages (ie the 1st 8 subkey words). Please provide full details of your working in doing this (ie all S-box lookups, rotations, XOR's).
Then provide the details of the initial AddRoundKey stage, and all round one stages. Again provide full details of your working in doing this (ie all S-box lookups, rotations, multiplications including modulo reductions, XOR's).
You can verify the results of your calculations by comparing them to the state and sub-key values given by the AES Calculator.
LawrieBrownXYZPQ".
Then translate this from ASCII into hexadecimal (see below).
This is a sample test message for Lawrie!Please ensure it is at least 35 and no more than 45 characters, that is it should incompletely span 3 input blocks of the cipher.
To convert from the ASCII text of your key/message to hexadecimal (and hence binary), you can:
l2-key,
and then ran the following command:
%od -x l2-key 0000000 4c61 7772 6965 4272 6f77 6e58 595a 5051 0000020 0aNote this gives the offset into the file of each 16 byte group, and then on successive lines lists the bytes in hexadecimal. Note the newline (\n) character at the end of the line, which I don't expect you to use in your key/message.
To show how you'd use these, I could for example implement the ECB mode (which is not what you are asked to do) as follows: given my key above, and the first 16 bytes of my message "This is a sample", I'd create the following key and plaintext hex values:
4c617772696542726f776e58595a5051 5468697320697320612073616d706c65
and then encrypt this using the AES Calculator
which tells me (using trace level 1):
setKey(4c617772696542726f776e58595a5051)
encryptAES(5468697320697320612073616d706c65) = 077191dae654d4aab7870760ff7d6ffe
hence my first block of ciphertext in ECB mode would be:
077191dae654d4aab7870760ff7d6ffe
Ci = AESK1(Pi XOR Ci-1)
C-1 = IV
You should explicitly discuss how you handle the final, undersize block,
and how the receiver determines which decrypted bytes are valid. This
is part of the assessment for this item.
You will find it relatively simple to implement the XOR's for this mode if you use a scientific calculator with the ability to enter and display numbers in various bases and to perform logical operations (eg. the Windows Calculator in Scientific Mode, or kcalc on Linux).
Ci = Pi XOR AESK1 (Ci-1)
C-1 = IV
and you will be using 128-bit feedback (ie all 16 bytes of ciphertext),
which can be done only after you have processed 16 distinct bytes
of the message.